package org.tech4j.edi.persistence.api.query;

import org.tech4j.edi.common.enums.RetryStatusEnum;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/7 11:45
 **/
public class RetryRecordQuery {

    /**
     * 重试id集合
     */
    private List<String> idList;

    /**
     * 业务单号集合
     */
    private List<String> bizNoList;

    /**
     * 最小id
     */
    private String minId;

    /**
     * 最大id
     */
    private String maxId;

    /**
     * 业务类型
     */
    private String bizType;

    /**
     * 开始时间
     */
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    private LocalDateTime endTime;

    /**
     * 环境隔离
     */
    private String env;

    /**
     * 最大查询大小
     */
    private Integer maxQuerySize;

    /**
     * 重试状态
     */
    private RetryStatusEnum retryStatus;
    /**
     * 扩展字段
     */
    private Map<String, String> extraField;

    private String shardingKey;

    public List<String> getIdList() {
        return idList;
    }

    public void setIdList(List<String> idList) {
        this.idList = idList;
    }

    public String getBizType() {
        return bizType;
    }

    public void setBizType(String bizType) {
        this.bizType = bizType;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public Map<String, String> getExtraField() {
        return extraField;
    }

    public void setExtraField(Map<String, String> extraField) {
        this.extraField = extraField;
    }

    public List<String> getBizNoList() {
        return bizNoList;
    }

    public void setBizNoList(List<String> bizNoList) {
        this.bizNoList = bizNoList;
    }

    public String getMinId() {
        return minId;
    }

    public void setMinId(String minId) {
        this.minId = minId;
    }

    public String getMaxId() {
        return maxId;
    }

    public void setMaxId(String maxId) {
        this.maxId = maxId;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public Integer getMaxQuerySize() {
        return maxQuerySize;
    }

    public void setMaxQuerySize(Integer maxQuerySize) {
        this.maxQuerySize = maxQuerySize;
    }

    public RetryStatusEnum getRetryStatus() {
        return retryStatus;
    }

    public void setRetryStatus(RetryStatusEnum retryStatus) {
        this.retryStatus = retryStatus;
    }


    public String getShardingKey() {
        return shardingKey;
    }

    public void setShardingKey(String shardingKey) {
        this.shardingKey = shardingKey;
    }

    public static final class Builder {
        private List<String> idList;
        private List<String> bizNoList;
        private String minId;
        private String maxId;
        private String bizType;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private String env;
        private Integer maxQuerySize;
        private RetryStatusEnum retryStatus;
        private Map<String, String> extraField;
        private String shardingKey;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder idList(List<String> idList) {
            this.idList = idList;
            return this;
        }

        public Builder bizNoList(List<String> bizNoList) {
            this.bizNoList = bizNoList;
            return this;
        }

        public Builder minId(String minId) {
            this.minId = minId;
            return this;
        }

        public Builder maxId(String maxId) {
            this.maxId = maxId;
            return this;
        }

        public Builder bizType(String bizType) {
            this.bizType = bizType;
            return this;
        }

        public Builder startTime(LocalDateTime startTime) {
            this.startTime = startTime;
            return this;
        }

        public Builder endTime(LocalDateTime endTime) {
            this.endTime = endTime;
            return this;
        }

        public Builder env(String env) {
            this.env = env;
            return this;
        }

        public Builder maxQuerySize(Integer maxQuerySize) {
            this.maxQuerySize = maxQuerySize;
            return this;
        }

        public Builder retryStatus(RetryStatusEnum retryStatus) {
            this.retryStatus = retryStatus;
            return this;
        }

        public Builder extraField(Map<String, String> extraField) {
            this.extraField = extraField;
            return this;
        }

        public Builder shardingKey(String shardingKey) {
            this.shardingKey = shardingKey;
            return this;
        }

        public RetryRecordQuery build() {
            RetryRecordQuery retryRecordQuery = new RetryRecordQuery();
            retryRecordQuery.setIdList(idList);
            retryRecordQuery.setBizNoList(bizNoList);
            retryRecordQuery.setMinId(minId);
            retryRecordQuery.setMaxId(maxId);
            retryRecordQuery.setBizType(bizType);
            retryRecordQuery.setStartTime(startTime);
            retryRecordQuery.setEndTime(endTime);
            retryRecordQuery.setEnv(env);
            retryRecordQuery.setMaxQuerySize(maxQuerySize);
            retryRecordQuery.setRetryStatus(retryStatus);
            retryRecordQuery.setExtraField(extraField);
            return retryRecordQuery;
        }
    }
}
